<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习</title>
</head>
<body>
    
</body>
<script>
    /*
        创建一个电影类
    */
    class Movie {  // class 关键字创建（类名的首字母大写）
        // 构造器（函数），共有的
        constructor(name,time){
            this.name = name;
            this.time = time;
            console.log("电影"+this.name+'将于'+this.time+'上映')
        }
        type(kind){
            console.log('我是一部'+this.kind)
        }
    }
    // new 实例化对象
    var qd = new Movie('穹顶之下','2015-07-12');
    var lz = new Movie('娜扎','2015-10-12');
    class SonMovie extends Movie {
        constructor(name,time,kind){
            super(name,time);
            this.kind = kind;
        }
        // type(kind){
        //     console.log(this);
        //     console.log('子类直接告诉我是一部'+kind)
        // }
    }
    var sm = new SonMovie('穹顶之下','2015-07-12','动作片');
    sm.type()




    /*
        运算类
    */
    // 必须先定义，才能使用
    class Calu {
        constructor(x,y){
            this.x = x;
            this.y = y;
        }
        add(){
            console.log('执行加法功能：');
            console.log(this.x + this.y)
        }
    }
    class CaluSub extends Calu {
        constructor(x,y,z){
            super(x,y);
            this.z = z;
        }
        sub(){
            console.log('执行剪发功能：');
            console.log(this.x - this.y + this.z)
        }
    }

    var cs = new CaluSub(5,1,2);
    cs.sub();
   




















</script>
</html>